﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
///Replay 的摘要说明
/// </summary>
public class Reply
{
    public Reply()
    {
        auther = new MemDisplay();
    }

    public Reply(int uid, int tid)
    {
        this.tid = tid;
    }

    public Reply(posts p, MemDisplay m)
    {
        this.tid = p.tid;
        this.title = p.title;
        this.text = p.text;
        this.post_ip = p.post_ip;
        this.posttime = p.posttime;
        this.pid = p.pid;
        if (p.edittime != null)
        {
            this.edittime = (DateTime)p.edittime;
        }
        if (p.edit_uid != null)
        {
            this.edituid = (int)p.edit_uid;
        }
        this.status = p.status;

        this.auther = m;
    }

    #region 变量声明

    public int tid;
    public MemDisplay auther;
    public string title;
    public string text;
    public string post_ip;
    public DateTime posttime;
    public DateTime? edittime;
    public int? edituid;
    public int status;
    public int pid;
    static int MINLEN = 10;
    #endregion

    public void SetTitle(string str)
    {
        //check?
        this.title = str;
    }

    public void SetText(string str)
    {
        if (str.Length < MINLEN)
        {
            //error message
        }
        else
        {
            this.text = str;
        }
    }

    public int Publish()
    {
        try
        {
            SaveData.NewPost(this);
            return 1;
        }
        catch (System.Exception ex)
        {
            return 0;
        }
    }

    public static void Del(int pid)//删除
    {
        try
        {
            SaveData.DelThread(pid);
        }
        catch (System.Exception ex)
        {

        }
    }
}
